<?php
$g4_path = "../"; 
require_once ($g4_path.'common.php');

$title = "전체 강의 시간표";
$menu = 3;
require_once ('./admin.head.php');
require_once ('./admin.lib.php');
$monthSelected = isset($_GET['month']) ? $_GET['month'] : date('m');
$yearSelected = isset($_GET['year']) ? $_GET['year'] : date('Y');
?>
<style type="text/css" >
    .w_sun,.w_sat {
            background-color:#ffffcc;
    }

</style>
<script>
function openTimeTable(year, month, day, dow) {
    window.open('pop_timetable_detail.php?year='+year+'&month='+month+'&day='+day+'&dow='+dow,'timetable','scrollbars=yes,width=500,height=400');
    return false;
}

</script>
<table width="100%" cellspacing="0" cellpadding="0" border="0" background="images/sub_bg.gif">
<tbody><tr>
<td><table width="823" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td background="images/sub_bg_title.gif"><img width="343" height="70" src="images/sub_title_friend.gif"/></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td valign="top" height="40"><table width="823" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td><img width="1" height="1" src="images/1blank.gif"/></td>
<td width="98" bgcolor="#000000" align="right"><a href="teacherCourseManage.php"><img width="85" height="24" border="0" src="images/sub_menu04_01.gif"/></a></td>
<td width="26" bgcolor="#000000"><img width="26" height="24" src="images/sub_menu_line.gif"/></td>
<td width="75" bgcolor="#000000"><a href="studentCourseManage.php"><img width="75" height="24" border="0" src="images/sub_menu04_02.gif"/></a></td>
<td width="26" bgcolor="#000000"><img width="26" height="24" src="images/sub_menu_line.gif"/></td>
<td width="48" bgcolor="#000000"><a href="bookManage.php"><img width="48" height="24" border="0" src="images/sub_menu04_03.gif"/></a></td>
<td width="26" bgcolor="#000000"><img width="26" height="24" alt="" src="images/sub_menu_line.gif"/></td>
<td width="93" bgcolor="#000000"><a href="courseTotal.php"><img width="85" height="24" border="0" src="images/sub_menu04_04.gif"/></a></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td><table width="823" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td valign="top"> </td>
<td valign="top" height="40"><img width="168" height="19" src="images/sub_menu04_title04.gif"/></td>
</tr>
<tr>
<td width="30" valign="top"><img width="1" height="1" src="images/1blank.gif"/></td>
<td valign="top" height="50"><table cellspacing="0" cellpadding="0" border="0" class="font">
<tbody><tr>
<td><img width="543" height="1" src="images/sub_company_01_01_line.gif"/></td>
</tr>
<tr>
<td><table width="100%" cellspacing="0" cellpadding="0" border="0" class="font">
<tbody><tr>
<td width="40" height="30"><img width="11" height="8" alt="" src="images/sub_company_01_01_img01.gif"/></td>
<td>
<form method="get">
<select id="select2" class="font" name="year">
<?php
    $year = date('Y') - 1;
    for($i = $year; $i <= $year+2; $i++) {
        if($i == $yearSelected) {
            $selected = 'selected = "selected"';
        } else {
            $selected = '';
        }
        echo "<option value=\"$i\" $selected>{$i}년</option>";
    }
?>
</select>
<select id="select8" class="font" name="month">
<?php

for($i = 1; $i <= 12; $i++) {
        if($i == $monthSelected) {
            $selected = 'selected = "selected"';
        } else {
            $selected = '';
        }
        echo "<option value=\"$i\" $selected>{$i}월</option>";
}
?>
</select>
<input type="submit" value="이동" />
</form>
</td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td><img width="543" height="1" src="images/sub_company_01_01_line.gif"/></td>
</tr>
<tr></tr>
</tbody></table>
<div align="center"/></td>
</tr>
<tr>
<td valign="top"><img width="1" height="1" src="images/1blank.gif"/></td>
<td valign="top"><table width="100%" cellspacing="0" cellpadding="0" border="0" class="font">
<tbody><tr>
<td><table width="793" cellspacing="0" cellpadding="3" bordercolor="#cccccc" border="2" style="border-collapse: collapse;" class="font">
<tbody><tr>
<td width="104" height="40" bgcolor="#ffffcc">일</td>
<td width="104" height="40">월</td>
<td width="104" height="40">화</td>
<td width="104" height="40">수</td>
<td width="104" height="40">목</td>
<td width="104" height="40">금</td>
<td width="109" height="40" bgcolor="#ffffcc">토</td>
</tr>
        <?php
            $now = mktime(0,0,0, $monthSelected, 1,$yearSelected);
            $limit = date('t', $now);
            $today = date('d', $now);
            $startDow = date('w', $now);

            $lastWeek = false;
            $days = 1-$startDow;
            $dows = array('w_sun','w_mon','w_tue','w_wed','w_thu','w_fri','w_sat');
            
            $sql = "SELECT sum(w_sun), sum(w_mon), sum(w_tue), sum(w_wed), sum(w_thu), sum(w_fri), sum(w_sat) from course where year = $yearSelected AND month = $monthSelected";
            
            $weekDays  = mysql_fetch_row(mysql_query($sql));


            while(!$lastWeek) :
            ?>
            <tr>
                <?php
                    for($i = 0; $i < 7; $i++, $days++) :
                ?>
                <td valign="top" height="40" class="<?php echo $dows[$i]?>"><?php if($days >= 1 && $days <= $limit)echo  $days?>
<?php
             if($weekDays[$i] > 0 && $days > 0 && $days <= $limit) :
?>
<br />
<img width="5" height="15" align="absmiddle" alt="" src="images/point_page_title.gif" />
<a onclick="return openTimeTable(<?php echo $yearSelected?>, <?php echo $monthSelected?>, <?php echo $days?>, '<?php echo $dows[$i]?>')" href="#"><?php echo $weekDays[$i]?>개 수업</a> 
<?php
                endif;
?>
                </td>
                <?php
                    if($days >= $limit) {
                        $lastWeek = true; 
                    }
                    endfor;
                ?>
            </tr>
            <?php
            endwhile;
            ?>
</tbody></table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>* 수업을 클릭하시면 자세한 수업정보를 확인 할 수 있습니다.</td>
</tr>
</tbody></table></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
<?php
require_once('admin.foot.php');
